<layout name="../Common/Master/master" />
<include file="../Common/Master/left" />
		<div class="orderright">
			<style>
				.orderlist table tr th{
					padding: 5px 20px;
				}
				.orderlist table tr.son th{
					color: orange;
					font-weight: normal;
				}
				.moren{
					border: none;
					padding: 5px;
					background: #ccc;
					cursor: pointer;
					border-radius: 5px;
				}
				.moren:hover{
					background: green;
					color: #fff;
				}
				.addrdel{
					border: none;
					padding: 5px;
					background: #ccc;
					cursor: pointer;
					border-radius: 5px;
				}
				.addrdel:hover{
					background: red;
					color: #fff;
				}
				.addaddr{
					display: inline-block;
					line-height: 20px;
					padding: 5px 0px;
					padding-right: 15px;
					color: #fff;
					border-radius: 5px;
					text-align: center;
					background: dodgerblue;
				}
				.addaddr:hover{
					background: blue;
				}
			</style>
			<div class="orderlist">
				<h2>我的地址 <a href="{:U('home/userinfo/addaddr')}" class="addaddr" >添加地址</a></h2>
				<table>
					 <tr>
						 <th>收货人</th>
						 <th>收货地址</th>
						 <th>联系方式</th>
						 <th>邮编</th>
						 <th>是否默认收货地址</th>
						 <th>操作</th>
					 </tr>
					<foreach name="addrs" item="vo">
					<tr class="son">
						<th>{$vo['postname']}</th>
						<th>{$vo['useraddr']}</th>
						<th>{$vo['phone']}</th>
						<th>{$vo['postcode']}</th>
						<th>
							<if condition="$vo['poststatus'] eq 1 ">是
								<else /> 否
							</if>
						</th>
						<th>
							<a href="{:U('home/userinfo/addaddr',['udid'=>$vo['udid']])}" style="margin-left: 10px;color: black" class="addrdel">修改</a>

							<if condition="$vo['poststatus'] eq 1 ">默认地址
							<else /><button  udid="{$vo['udid']}" class="moren">设为默认</button>
							<button udid="{$vo['udid']}" style="margin-left: 10px" class="addrdel">删除</button>

						</if>
						</th>
					</tr>
					</foreach>
				 </table>
			</div>
		</div>
	</div>
<script>
	$('.moren').click(function(){
		var udid=$(this).attr('udid');
		$.post("{:U('home/userinfo/moren')}",{udid:udid},function(res){
            if(res.valid){
				layer.alert('设置成功', {icon: 6}, function(index){
					location.reload();
					layer.close(index);
				});
			}else{
				layer.msg('设置失败');
			}
		},'json');
	})
	$('.addrdel').click(function(){
		var udid=$(this).attr('udid');
		$.post("{:U('home/userinfo/deladdr')}",{udid:udid},function(res){
			if(res.valid){
				layer.alert(res.msg, {icon: 6}, function(index){
					location.reload();
					layer.close(index);
				});
			}else{
				layer.msg(res.msg);
			}
		},'json');
	})
</script>


